﻿function Right(str, n) {
  if (n <= 0)
    return "";
  else if (n > String(str).length)
    return str;
  else {
    var iLen = String(str).length;
    return String(str).substring(iLen, iLen - n);
  }
}

function ShowTime() {
  var v = (new Date());
  var h, m, s, Y, M, D, WD, ss;

  Y = '20' + Right(v.getYear(), 2);
  M = v.getMonth() + 1;
  D = v.getDate();
  WD = v.getDay();

  h = v.getHours();
  m = v.getMinutes();
  s = v.getSeconds();

  switch (WD) {
    case 0: WD = 'Ch&#7911; nh&#7853;t'; break;
    case 1: WD = 'Th&#7913; 2'; break;
    case 2: WD = 'Th&#7913; 3'; break;
    case 3: WD = 'Th&#7913; 4'; break;
    case 4: WD = 'Th&#7913; 5'; break;
    case 5: WD = 'Th&#7913; 6'; break;
    case 6: WD = 'Th&#7913; 7'; break;
  }
  if (M < 10) M = '0' + M;

  ss = "".concat((h < 10) ? '0'.concat(h) : h).concat(':').concat((m < 10) ? '0'.concat(m) : m).concat(':').concat((s < 10) ? '0'.concat(s) : s);
  ss = WD + ', ' + D + '-' + M + '-' + Y + ', ' + ss;
  document.getElementById('timeHeader').innerHTML = ss;
}

function ShowRealTime(){
  ShowTime();
  setInterval('ShowTime()', 1000);
}